module(...,package.seeall)
import "android.animation.ObjectAnimator"
import "android.animation.AnimatorSet"
import "android.view.animation.DecelerateInterpolator"
import "android.view.animation.AccelerateInterpolator"
import "android.animation.AnimatorListenerAdapter"

--local FloatButtonAnim={}

function show(view)
  view.parent.Visibility=View.VISIBLE
  local animatorSet = AnimatorSet()
  local scaleX=ObjectAnimator.ofFloat(view.parent,"scaleX",{1})
  local scaleY=ObjectAnimator.ofFloat(view.parent,"scaleY",{1})
  animatorSet.setDuration(200)
  animatorSet.setInterpolator(DecelerateInterpolator())
  animatorSet.play(scaleX).with(scaleY)
  animatorSet.start()
  return view
end
function hide(view)
  local animatorSet=AnimatorSet()
  local scaleX=ObjectAnimator.ofFloat(view.parent,"scaleX",{0})
  local scaleY=ObjectAnimator.ofFloat(view.parent,"scaleY",{0})
  animatorSet.setDuration(200)
  animatorSet.setInterpolator(AccelerateInterpolator())
  animatorSet.play(scaleX).with(scaleY)
  animatorSet.addListener(AnimatorListenerAdapter({
    onAnimationEnd=function(animation)
      view.parent.Visibility=View.GONE
    end
  }))
  animatorSet.start()
  return view
end
function open(view)
  ObjectAnimator.ofFloat(view.parent, "elevation", {math.dp2int(12)})
  .setDuration(200)
  .setInterpolator(DecelerateInterpolator())
  .start()
  return view
end
function close(view)
  ObjectAnimator.ofFloat(view.parent, "elevation", {math.dp2int(6)})
  .setDuration(200)
  .setInterpolator(AccelerateInterpolator())
  .start()
  return view
end
--return FloatButtonAnim